package zero.tech.games.gate.topic;

import java.util.Map;

import com.alibaba.fastjson.JSONObject;

import zero.tech.core.data.Resp;
import zero.tech.games.common.Code;
import zero.tech.games.common.TopicOrder;
import zero.tech.games.common.marquee.MarqueeAll;
import zero.tech.games.common.marquee.MarqueeContent;
import zero.tech.games.gate.data.GATECMD;
import zero.tech.redis.topic.TopicChannelType;
import zero.tech.redis.topic.TopicProcess;
import zero.tech.wsnet.controller.CacheOnline;
import zero.tech.wsnet.controller.Controller;
import zero.tech.wsnet.data.Message;

public class MarqueeAllTopic extends TopicProcess{

	@Override
	public String orderType() {
		return TopicOrder.MARQUEE_ALL;
	}

	@Override
	public void process(String message) throws Exception {
		MarqueeAll marquee = JSONObject.parseObject(message, MarqueeAll.class);
		Map<Integer,Controller> onlines=CacheOnline.getCache().getOnlines();
		MarqueeContent marqueeContent =new MarqueeContent(marquee.getMsg());
		for(Controller controller:onlines.values()) {
			controller.getWebClient().sendMessage(Message.build(GATECMD.NOTIFY_MARQUEE, Resp.build(Code.OK, "跑马灯到达",marqueeContent)));
		}
	}

	@Override
	public TopicChannelType channelType() {
		return TopicChannelType.MARQUEE;
	}

}
